using MediatR;
using Microsoft.AspNetCore.Mvc;
using WMS_Goodsinfo.Api.Read.Application.Command;
using WMS_Goodsinfo.Api.Read.DTOS;
using WMS_Goodsinfo.ErrorCode;

namespace WMS_Goodsinfo.Api.Read.Controllers
{
    /// <summary>
    /// 台账服务
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    public class ProductController : ControllerBase
    {
        private readonly IMediator _mediator;

        public ProductController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取商品列表
        /// </summary>
        /// <param name="command">查询条件</param>
        /// <returns>分页商品列表</returns>
        [HttpGet("list")]
        public async Task<ApiPaging<ProductDtoList>> GetProductList([FromQuery] GetProductListCommand command)
        {
           
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取出入库流水列表
        /// </summary>
        /// <param name="command">查询条件</param>
        /// <returns>分页出入库流水列表</returns>
        [HttpGet("inout-list")]
        public async Task<ApiPaging<InOutListDto>> GetInOutList([FromQuery] SelectInoutListCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取仓库分布库存列表
        /// </summary>
        /// <param name="command">查询条件</param>
        /// <returns>分页仓库分布库存列表</returns>
        [HttpGet("warehouse-list")]
        public async Task<ApiPaging<WarehouseDto>> GetWarehouseList([FromQuery] SelectWarehousCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取保质期查询列表
        /// </summary>
        /// <param name="command">查询条件</param>
        /// <returns>分页保质期查询列表</returns>
        [HttpGet("shelflife-list")]
        public async Task<ApiPaging<ShlflifeDto>> GetShelflifeList([FromQuery] SelectShelflifeCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 查询批次数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet("batch-list")]
        public async Task<ApiPaging<BatchListDto>> GetBatchList([FromQuery]SelectBatchCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 查询批次流水
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet("batchflow-list")]
        public async Task<ApiPaging<BatchFlowDto>> GetBatchFlowList([FromQuery]SelectBatchflowCommand request)
        {
            return await _mediator.Send(request);
        }


    }
} 